package com.hgw.easyexceldemo.domain;

import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.format.DateTimeFormat;
import com.alibaba.excel.annotation.format.NumberFormat;
import com.alibaba.excel.annotation.write.style.*;
import com.alibaba.excel.enums.poi.FillPatternTypeEnum;
import lombok.Data;
import org.springframework.core.annotation.Order;

import java.util.Date;

/**
 * Description:
 * Data time:2022/8/30 14:46
 * Author:TQ-3038-HuangGongWei
 */
@Data
@ContentRowHeight(15)
@HeadRowHeight(20)
@ColumnWidth(15)
// 头背景设置成红色 IndexedColors.RED.getIndex()
@HeadStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 10)
// 头字体设置成20
@HeadFontStyle(fontHeightInPoints = 20)
// 内容的背景设置成绿色 IndexedColors.GREEN.getIndex()
@ContentStyle(fillPatternType = FillPatternTypeEnum.SOLID_FOREGROUND, fillForegroundColor = 17)
// 内容字体设置成20
@ContentFontStyle(fontHeightInPoints = 12)
public class User {
    /**
     * 我想所有的 字符串起前面加上"自定义："三个字
     */
    @ExcelProperty({"用户表","姓名"})
    @Order(0)
    private String string;
    /**
     * 我想写到excel 用年月日的格式
     */
    @DateTimeFormat("yyyy年MM月dd日HH时mm分ss秒")
    @ExcelProperty({"用户表","出生日期"})
    @Order(1)
    @ColumnWidth(36)
    private Date date;
    /**
     * 我想写到excel 用百分比表示
     */
    @NumberFormat("#.##%")
    @ExcelProperty({"用户表","成绩比"})
    @Order(2)
    private Double doubleData;
}
